import { cancelOrder, confirmReceipt, getClearReason } from '@/api/after-sale'

// 获取取消订单原因
export const getCancelReason = async () => {
  const res = await getClearReason('CANCEL')
  if (res.data.success) {
    return res.data.result
  }
}

// 取消订单
export const confirmCancelOrder = async (orderSn: string, reason: any) => {
  const res = await cancelOrder(orderSn, { "reason": reason })
  if (res.data.success) {
    uni.showToast({
      title: '取消成功',
      icon: 'none',
      duration: 2000
    })
    return true
  } else {
    return false
  }
}


// 确认收货
export const confirmDeliver = async (orderSn: string) => {
  const res = await confirmReceipt(orderSn)
  if (res.data.success) {
    uni.showToast({
      title: '确认收货成功',
      icon: "none"
    })
    return true
  } else {
    return false
  }
}
